from flask import Flask

from settings import DevelopmentConfig

from apps.views.blog_view import blog_bp
from apps.views.house_view import house_bp
from apps.views.ent_view import ent_bp
from apps.views import index_bp
from apps.views.error_view import error_bp


def create_app():
    app = Flask(__name__, template_folder='../templates')
    # 当把flask的创建移动到init中时，需要指定模板路径。
    # flask的创建文件需要与templates在同一层级
    # 加载配置
    app.config.from_object(DevelopmentConfig)
    # 注册蓝图
    app.register_blueprint(index_bp)
    app.register_blueprint(blog_bp)
    # 可以路径加前缀，等同于在创建蓝图的时候加前缀
    # app.register_blueprint(blog_bp, url_prefix='/blog')
    app.register_blueprint(house_bp)
    app.register_blueprint(ent_bp)
    app.register_blueprint(error_bp)
    return app
